package com.study.thread;

/**
 * @PACKAGE_NAME: com.study.thread
 * @CLASS_NAME: CreateThread
 * @USER: kagura
 * @Description TODO 创建多线程的两种方法，创建Thread派生类，实现Runnable接口
 * @Date 2021/3/3 9:58 上午
 * @MONTH_NAME_FULL: 三月
 * @DAY: 03
 * @DAY_NAME_FULL: 星期三
 * @PROJECT_NAME: Study
 **/
public class CreateThread {
    public static void main(String[] args) {
        Thread t1 = new MyThread();
        t1.start(); // 启动新线程

        Thread t2 = new Thread(new MyRunnable());
        t2.start(); // 启动新线程
    }
}

// 从Thread派生一个自定义类
class MyThread extends Thread {

    @Override
    public void run() {
        System.out.println("派生自定义类MyThread线程启动");
    }
}

// 实现Runnable接口
class MyRunnable implements Runnable {

    @Override
    public void run() {
        System.out.println("实现Runnable接口线程启动");
    }
}
